﻿using System;
using System.Collections.Generic;
using System.Text;
using Evaluant.Uss.ObjectContext;

namespace Application.Services
{
public class ServiceFactory
{
    protected static ObjectService os;

    /// <summary>
    /// Initializes the <see cref="ServiceFactory"/> class.
    /// </summary>
    static ServiceFactory()
    {
        // Determines whether the service is hosted in ASP.Net or not
        string path = System.Web.Hosting.HostingEnvironment.IsHosted
            ? System.Web.Hosting.HostingEnvironment.MapPath("~/engines.config")
            : "engines.config";
        
        os = new ObjectService(path);
    }

    /// <summary>
    /// Creates the service.
    /// </summary>
    /// <returns></returns>
    public static IService CreateService()
    {
        return new EussService(os.CreateObjectContext());
    }
}
}
